class Functor {
    constructor (value) {
        this._value = value
    }

    map (f) {
        return new Functor(f(this._value))
    }

    value (f) {
        return f(this._value)
    }
}

// $299.9 => ￥2100+
const toRMB = money => new Functor(money)
    .map(v => v.replace('$', ''))
    .map(parseFloat)
    .map(v => v*7)
    //保留两个小数点
    .map(v => v.toFixed(2))
    .value(v => '￥' + v)

console.log(toRMB('$299.9'));